<%@page import="beans.Shop"%>
<%@page import="beans.Task"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link href="<%=path%>/admin/css/haiersoft.css" rel="stylesheet"
	type="text/css" />
<link href="<%=path%>/admin/css/print.css" rel="stylesheet"
	type="text/css" media="print" />
<script src="<%=path%>/admin/js/jquery-1.10.1.min.js"></script>
<script src="<%=path%>/admin/js/side.js" type="text/javascript"></script>
<script src="<%=path%>/admin/js/function.js" type="text/javascript"></script>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
<![endif]-->
<script type="text/javascript">
$(function() {
	// 隔行显示，鼠标停留显示整行
	$('tbody>tr:not(#search)').each(function(){
			this.onmouseover = function() {
				this.style.backgroundColor = '#E0FFFF';
			};
	});
	$('tbody>tr:odd:not(#search)').each(function(){
		this.onmouseout = function() {
			this.style.backgroundColor = '#fff';
		};
	});
	$('tbody>tr:even:not(#search)').each(function(){
		this.onmouseout = function() {
			this.style.backgroundColor = '#edf5ff';
		};
		this.style.backgroundColor = '#edf5ff';
	});
});
</script>
</head>

<body>
	<!-- MainForm -->
	<div id="MainForm">
		<div class="form_boxA">
			<h2>商铺列表<button style="margin-left:50px;" onclick="location='<%=path%>/ShopOperationServlet?operation=add'">添加商铺</button></h2>
			<table>
			<thead>
				<tr>
					<th>编号</th>
					<th>商铺名称</th>
					<th>电话</th>
					<th>地址</th>
					<th>是否营业</th>
					<th>描述</th>
					<th>操作</th>
				</tr>
				</thead>
				<tbody>
				<%
					@SuppressWarnings("unchecked")
					List<Shop> shops = (List<Shop>) request.getAttribute("shops");
					for (Shop shop : shops) {
				%>
				<tr>
					<td><%=shop.getId()%></td>
					<td><%=shop.getName()%></td>
					<td><%=shop.getTel()%></td>
					<td><%=shop.getAddress()%></td>
					<td><%=shop.getStatus()%></td>
					<td><%=shop.getShopDescribe()%></td>
					<td><a href="<%=path%>/ShopOperationServlet?operation=alt&id=<%=shop.getId()%>">修改</a> | <a href="javascript:void(0)"
						onclick="deleteTr(this,'ShopOperationServlet','<%=path%>')">删除</a> | <a href="<%=path%>/GoodServlet?id=<%=shop.getId()%>">商品管理</a></td>
				</tr>
				<%
					}
				%>
				</tbody>
			</table>
			<script type="text/javascript">
				function toPage(pageNum) {
					var page = document.getElementById('page');
					var searchForm = document.getElementById('searchForm');
					var count = ${count};
					var maxPage = parseInt(count / 15) + 1;
					if (pageNum < 1)
						page.value = 1;
					else if (pageNum > maxPage)
						page.value = maxPage;
					else
						page.value = parseInt(pageNum);
					searchForm.submit();
				}
			</script>
			<!-- PageNum -->
			<ul id="PageNum">
				<li><a href="javascript:toPage(1)">首页</a></li>
				<li><a href="javascript:toPage(${page }-1)">上一页</a></li>
				<li><a href="javascript:void(0)">${page }</a></li>
				<li><a href="javascript:toPage(${page }+1)">下一页</a></li>
				<li><a href="javascript:toPage(${count/15+1 })">尾页</a></li>
			</ul>
			<!-- /PageNum -->
			<p class="msg">共找到${count }条记录，当前显示从第${(page-1)*15+1 }条至第${page*15>count?count:page*15 }条</p>
		</div>
	</div>
	<!-- /MainForm -->

</body>
</html>